<?php

namespace app\common\job;

use app\common\service\ExternalSourcePushService;
use think\queue\Job;

/**
 * 新案源推送给律师
 * Class ExternalSourcePush
 * @package app\common\job
 */
class ExternalSourcePush
{
    /**
     * fire是消息队列默认调用的方法
     * @param Job $job 当前的任务对象
     * @param array|mixed $data 发布任务时自定义的数据
     */
    public function fire(Job $job, $data)
    {
        $id = $data['id'] ?? '';

        try {

            $this->getExternalSourcePushService()->pushToLawyers($id);

        } finally {
            $job->delete();
        }

    }


    private function getExternalSourcePushService(): ExternalSourcePushService
    {
        return app(ExternalSourcePushService::class);
    }
}
